<%@page import="com.edu.dreams.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>童话世界</title>
<meta name="description" content="一个充满童话世界的地方，带你回味童年." />
<meta name="keywords" content="童话、英雄和魔法" />
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- 引入bootstrap 样式文件 -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- 引入我们自己的首页样式文件 -->
<link rel="stylesheet" href="css/index2.css">
<!-- 先引入jquery js文件 -->
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/index2.js"></script>
<!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>

<!--  获取用户登录名 --> 
<%
	User user = (User) request.getSession().getAttribute("user");
%>

<body>
	<!-- 导航栏 -->
	<nav class="navbar navbar-default">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed"
					data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
					aria-expanded="false">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand"
					href="${pageContext.request.contextPath}/home"><img
					style="margin-left: 15px;" src="images/logo.jpg" alt="童话世界"></a>
			</div>

			<div class="collapse navbar-collapse"
				id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<li class="active"><a
						href="${pageContext.request.contextPath}/home">首页 <span
							class="sr-only">(current)</span></a></li>
					<li><a href="${pageContext.request.contextPath}/animations">动画</a></li>
					<li><a href="${pageContext.request.contextPath}/news">资讯</a></li>
					<li><a href="${pageContext.request.contextPath}/rank">排行榜</a></li>
					<li><a href="${pageContext.request.contextPath}/personal">个人中心</a></li>
				</ul>
				<form action="${pageContext.request.contextPath}/searchAnim"
					method="post" class="navbar-form navbar-left">
					<div class="form-group">
						<input type="text" name="animname" class="form-control"
							placeholder="搜索动画">
					</div>
					<button type="submit" class="btn btn-default">搜索</button>
				</form>
				<ul class="nav navbar-nav navbar-right">
					<li><a href="${pageContext.request.contextPath}/personal"><%=user.getUser_name()%> </a></li>
					<li><a href="${pageContext.request.contextPath}/logout">退出登录</a></li>
				</ul>
			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container-fluid -->
	</nav>

	<!-- 轮播图 -->
	<div class="container">
		<div id="carousel-example-generic" class="carousel slide"
			data-ride="carousel">
			<!-- 轮播标志小圆点 -->
			<ol class="carousel-indicators">
				<li data-target="#carousel-example-generic" data-slide-to="0"
					class="active"></li>
				<li data-target="#carousel-example-generic" data-slide-to="1"></li>
				<li data-target="#carousel-example-generic" data-slide-to="2"></li>
			</ol>

			<!-- 图片 -->
			<div class="carousel-inner" role="listbox">
			<%-- <c:forEach>标签是更加通用的标签，因为它迭代一个集合中的对象。 --%>
			<!-- items	要被循环的信息    var	代表当前条目的变量名称  varStatus	代表循环状态的变量名称 -->
			<%-- <c:choose>标签与Java switch语句的功能一样，用于在众多选项中做出选择。 --%>
				<c:forEach var="item" begin="0" end="2" items="${animdata}" varStatus="status">
					<c:choose>
						<c:when test="${status.first}">
							<div class="item active">
								<a
									href="${pageContext.request.contextPath}/animationshow?id=${item.anim_id}"><img
									src="${pageContext.request.contextPath}/upload/${item.anim_picurl}"
									alt="${item.anim_name}"></a>
								<div class="carousel-caption">${item.anim_name}</div>
							</div>
						</c:when>
						<c:otherwise>
							<div class="item">
								<a
									href="${pageContext.request.contextPath}/animationshow?id=${item.anim_id}"><img
									src="${pageContext.request.contextPath}/upload/${item.anim_picurl}"
									alt="${item.anim_name}"></a>
								<div class="carousel-caption">${item.anim_name}</div>
							</div>
						</c:otherwise>
					</c:choose>
				</c:forEach>
			</div>

			<!-- 左右按钮 -->
			<a class="left carousel-control" href="#carousel-example-generic"
				role="button" data-slide="prev"> <span
				class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
				<span class="sr-only">上一张</span>
			</a> <a class="right carousel-control" href="#carousel-example-generic"
				role="button" data-slide="next"> <span
				class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
				<span class="sr-only">下一张</span>
			</a>
		</div>
	</div>

	<br />
	<!-- 主体内容 1-->
	<div class="container" style="margin-top: 40px;">
		<c:forEach var="item" begin="0" end="2" items="${animdata}"
			varStatus="status">
			<div class="row">
				<div class="col-md-4 col-xs-12">
					<a
						href="${pageContext.request.contextPath}/animationshow?id=${item.anim_id}">
						<img class="img-responsive"
						src="${pageContext.request.contextPath}/upload/${item.anim_picurl}"
						alt="${item.anim_name}">
					</a>
				</div>
				<div class="col-md-8 col-xs-12">
					<h4 style="margin: 50px 0 50px;">
						${item.anim_jieshao.length()>300?item.anim_jieshao.substring(0,300):item.anim_jieshao}...</h4>
				</div>
			</div>
			<br />
		</c:forEach>
	</div>

	<!-- 主体内容 2-->
	<div class="container">
		<h3>作品赏析</h3>
	</div>

	<div class="container">
		<div class="row item" style="display: block;">
			<c:forEach var="item" items="${datas.list}">
				<div class="col-sm-12 col-md-4">
					<div class="thumbnail">
						<img width="350" height="219"
							src="${pageContext.request.contextPath}/upload/${item.anim_picurl}"
							alt="${item.anim_name}">
						<div class="caption">
							<h4 style="text-align: center;">${item.anim_name}</h4>
							<p>${item.anim_jieshao}</p>
							<p>
								<a
									href="${pageContext.request.contextPath}/animationshow?id=${item.anim_id}"
									class="btn btn-primary" role="button">了解详情</a> <a
									href="${pageContext.request.contextPath}/addShouCang?aname=${item.anim_name}"
									class="btn btn-primary" role="button">收藏</a>
							</p>
						</div>
					</div>
				</div>
			</c:forEach>
		</div>
	</div>

	<!-- 页面尾部 -->
	<div class="container text-center">
		<nav aria-label="Page navigation">
			<ul class="pagination">
				<li><a
					href="${pageContext.request.contextPath}/home?startPage=1">&laquo;</a></li>
				<c:choose>
					<c:when test="${datas.pageNum-1>0}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pageNum-1}">上一页</a></li>
					</c:when>
					<c:when test="${datas.pageNum-1<=0}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=1">上一页</a></li>
					</c:when>
				</c:choose>
				<c:choose>
					<c:when test="${datas.pages==0}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pageNum}">下一页</a></li>
					</c:when>
					<c:when test="${datas.pageNum+1<datas.pages}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pageNum+1}">下一页</a></li>
					</c:when>
					<c:when test="${datas.pageNum+1>=datas.pages}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pageNum+1}">下一页</a></li>
					</c:when>
				</c:choose>
				<c:choose>
					<c:when test="${datas.pages==0}">
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pageNum}">&raquo;</a></li>
					</c:when>
					<c:otherwise>
						<li><a
							href="${pageContext.request.contextPath}/home?startPage=${datas.pages}">&raquo;</a></li>
					</c:otherwise>
				</c:choose>
			</ul>
		</nav>
	</div>
	<div class="footer container">
		<hr>
		<p class="text-center">2020-forever</p>
	</div>
</body>
</html>